package com.apes.scm.masterdata.finance.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @desc 银行信息
 *
 * @author Bieb
 * @create 2018年8月9日15:16:31
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = Bank.CONST_TABLE_NAME, indexes = {
        @Index(name = "IDX_MAS_BANK", columnList = "NAME", unique = true)
})
public class Bank extends Model {
    public static final String CONST_TABLE_NAME = "mas_bank";

    @Id
    @Comment("银行编码")
    @Column(name = "id", nullable = false, length = 120)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "银行编码", padding = 6)
    private String id;

    @Comment("银行名称")
    @Column(name = "name", nullable = false, length = 64)
    private String name;

    @Comment("有效性")
    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 1")
    private boolean valid = true;
}
